<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS While</title>
    <script>

        function testWhile() {
            var x = ""
            var i = 1;
            do {
                x = x + "The number is " + i + "<br/>";
                i++;
            }while (i<5)

            while (i < 10){
                x = x + "The number is " + i + "<br/>";
                i++;
            }

            alert(x)
        }

        function testWhileTwo() {

            cars=["BMW","Volvo","Saab","Ford"];
            var j=0;
            for (;cars[j];)
            {
                document.write(cars[j] + "<br/>");
                j++;
            }
            var  m = 0;
            while (cars[m]){
                document.write(cars[m] + "<br/>");
                m++;
            }
            alert("Hello  finished")  /*  */
        }

    </script>
</head>
<body>
    <button onclick="testWhile()">点击这里</button>
    <button onclick="testWhileTwo()">点击这里这是第二项</button>
</body>
</html>